[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加用户</title>
 
<link rel="stylesheet" type="text/css" href="${base}/css/date.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/base.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/form.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/pop.css" />


<script type="text/javascript" src="${base}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-forms.js"></script>
<script type="text/javascript" src="${base}/commonjs/message/message.js"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog6/dialog-plus-min.js"></script>
<script type="text/javascript" src="${base}/commonjs/noty/jquery.noty.packaged.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-validation/jquery.validate.min.js" ></script>
<script type="text/javascript" src="${base}/commonjs/jquery-validation/localization/messages_zh.js" ></script>
<script type="text/javascript" src="${base}/commonjs/tab/tabs.js"></script>
</head>
<body>
<!-- 主体开始 -->
<div class="dataForm">
<div class="eva_content_top">
	<ul id="eva_all">
		<li><a tab="eva_tab1" class="eva_focus" href="javascript:void(0);">基本信息</a></li>
		<li><a tab="eva_tab2" class="white" href="javascript:void(0);">用户角色</a></li>
	</ul>
</div>
		<div id="eva_tab1" class="eva_tab">
			<form id="dataform" action="add" method="post">
				<div class="content mt10">
				<input type="hidden" name="rolesid" id="rolesid">
					<dl>
					<dt><span   class="required">*</span>账号</dt>
					<dd>			
					<input  class="required " name="account" id="account"  type="text"  />
					</dd>
					
					<dt><span   class="required">*</span>密码</dt>
					<dd>			
					<input  class="required  password" name="password" id="password"  type="password"  />
					</dd>
					
					<dt><span   class="required">*</span>确认密码</dt>
					<dd>			
					<input  class="required " equalTo="#password" name="confirm_password" id="confirm_password"  type="password"  />
					</dd>
					<dt><span   class="required">*</span>姓名</dt>
					<dd>			
					<input  class="required " name="name" id="name"  type="text"  />
					</dd>
		
					<dt>性别</dt>
					<dd>
						[@c.radios id="gender"  attributes='class="radioGroup"' input_attributes='style="width:20px;"' datas="common.sex" /]
					</dd>
					<dt>备注</dt>
					<dd>
						<textarea rows="5" cols="38" id="description" name="description" ></textarea>
					</dd>
					<dl>
		
					<div class="clear"></div>
				</div>
				<div class="pop_btn">
					<input type="button" id="butSave" class="btn_1" value="保存"/>
					<input type="button" id="butCancel" class="btn_1" value="取消"/>
			    </div>
			</form>						
		</div>	
		<div id="eva_tab2" class="eva_tab">
				<div class="userole">
					<div class="mt10"><span   class="required">*</span>用户角色：</div>										
					<dl>
				   [#if roles??]
				      [#list roles as item]
				        [#if item.id!=1]
				         <dt><input type="checkbox" id="roles${item.id}}" name="roles"/ value="${item.id}"> ${item.name}</dt>
				        [/#if]
				      [/#list]
				   [/#if]
					</dt>					
					<dl>		
					<div class="clear"></div>
				</div>				
		</div>
			
</div>
<script type="text/javascript">	
	$(function() {
		// 保存
		var rolesid = [];
		$("#butSave").click(function(){		     			     
			$("input[name='roles']").each(function(){
				if($(this).attr("checked")=="checked"){
					rolesid.push($(this).attr("value"));
				}
			});
			// 检查是否选择一个
			var len = $("input[type='checkbox'][name='roles']:checked").length;
            if(len>0){
		      $("#rolesid").val(rolesid);
		    }
			 $("#dataform").submit();
			
  		 });

		var v = jQuery("#dataform").validate({
		 submitHandler: function(form) {
			$(form).ajaxSubmit({
			    url:"add",
				success: function(data){  
                        noty({
                          text:extendMessages(data).msg.message,
                          layout:"center",
                          timeout:2000,
                          callback:{
                             afterClose:function(){
                                          window.parent.location.reload(); 
                                        }
                           }
                        });
               }
			});
		}
 });
		$("#butCancel").click(function(){
				window.parent.closeArtDialog();
				
		});		
	});
$(function() {
		$("#submitRoles").click(function(){	
		$("#eva_all li a").removeClass().addClass("white");
		$("#eva_all li:first").removeClass().addClass("eva_focus");
    $("#eva_tab2").hide();
    $("#eva_tab1").show();
	});	
 });	
</script>

</body>
</html>